package com.lin.controller;


import com.lin.base.Result;
import com.lin.entity.Department;
import com.lin.entity.Userinfo;
import com.lin.entity.UserinfoDto;
import com.lin.service.impl.DepartmentServiceImpl;
import com.lin.service.impl.UserinfoServiceImpl;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lin
 * @since 2022-06-17
 */
@RestController
@RequestMapping("/api/user")
public class UserinfoController {

    @Resource
    UserinfoServiceImpl userinfoService;

    @GetMapping("/list")
    public Result getUserinfo(@RequestParam Integer page,
                              @RequestParam Integer size,
                              @RequestParam Integer condition,
                              @RequestParam String key) {
        return Result.ok(userinfoService.getUserinfo(page,size,condition,key));
    }

    @PostMapping("/add")
    public Result addUserinfo(@RequestBody UserinfoDto dto) {
        return Result.ok(userinfoService.addUserinfo(dto));
    }

    @PostMapping("/update")
    public Result updateDepartment(@RequestBody Userinfo userinfo) {
        return Result.ok(userinfoService.updateUserinfo(userinfo));
    }

    @PostMapping("/remove")
    public Result removeDepartment(@RequestParam Integer uid) {
        return Result.ok(userinfoService.removeUserinfo(uid));
    }
}
